import request from '@/utils/request'

/**
 * 用户当前布局查询
 * @returns {AxiosPromise}
 */
export function queryLayout() {
  return request({
    url: 'rest/api/view/user',
    method: 'get'
  })
}

/**
 * 用户保存布局
 * @param data
 * @returns {AxiosPromise}
 */
export function saveLayout(data) {
  return request({
    url: 'rest/api/view/user/create',
    method: 'post',
    data: data
  })
}

/**
 * 用户更新布局
 * @param data
 * @returns {AxiosPromise}
 */
export function updateLayout(data) {
  return request({
    url: 'rest/api/view/user/update',
    method: 'post',
    data: data
  })
}

/**
 * 用户删除栏目
 * @param ids
 * @returns {AxiosPromise}
 */
export function deleteColumn(ids) {
  return request({
    url: 'rest/api/view/user/delColumn?cid=' + ids,
    method: 'get'
  })
}

/**
 * 加载用户默认模版
 */
export function loadUserLayout() {
  return request({
    url: 'rest/api/user/center/layout',
    method: 'get'
  })
}

export function setDefaultLayout(params) {
  return request({
    url: 'rest/api/user/center/default',
    method: 'get',
    params: params
  })
}

export function deleteUserCustomLayout(params) {
  return request({
    url: 'rest/api/user/center/del',
    method: 'post',
    params: params
  })
}

export function updateUserCustomLayout(data) {
  return request({
    url: 'rest/api/user/center',
    method: 'post',
    data: data
  })
}

export function queryUserSc(params) {
  return request({
    url: 'rest/api/service/list/app/auth/sc/all',
    method: 'get',
    params: params
  })
}

export default {
  queryLayout,
  saveLayout,
  deleteColumn,
  updateLayout,
  queryUserSc
}
